<?php
class UsersController extends AppController
{
	var $name = 'Users';
	var $components = array('Auth');

	function beforeFilter()
	{
		$this->Auth->allow('index', 'register', 'view');
		$this->Auth->userScope = array('User.is_active' => true);
	}

	function index()
	{
		$this->set('users', $this->User->find('all'));
	}

	function view($id = null)
	{
		$this->pageTitle = 'y';
		$this->User->id = $id;
		$this->set('user', $this->User->read());
	}

	function register()
	{
		if (!empty($this->data))
		{
			if ($this->User->save($this->data))
			{
				$this->Session->setFlash('欢迎你加入悦淘会，请到你刚才填写的邮箱去完成最后一步吧。');
				$this->redirect(array('action' => 'index'));
//				$this->flash('欢迎你加入悦淘会，请到你刚才填写的邮箱去完成最后一步吧。', '/users/register');
			}
//			else
//			{
//				$this->flash('注册失败，请稍后再试，谢谢。', '/users/register');
//			}
		}
	}

	function login()
	{
	}

	function logout()
	{
		$this->Auth->logout();
		$this->redirect('/');
//		$this->redirect($this->Auth->logout());
	}
}
?>
